<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file = "../../../cfgcaminhos.asp" -->
<%
	Response.Clear()
	Response.ContentType = "text/html"
	'Response.Charset = "ISO-8859-1"
	Response.Expires = 0
	Response.ExpiresAbsolute = Now() - 1
	Response.AddHeader "pragma","no-cache"
	Response.AddHeader "cache-control","private"
	Response.CacheControl = "no-cache"
%>
<%
	
	Dim doWrite
	Dim dbNomeTabela
	Dim dbNomeCampo
	Dim dbCampoCodigo
	Dim dbValorCampoCondicao
	Dim dbCampoResposta
	Dim dbCampoAtualizacaoTipo
	Dim novoValor
	Dim didAction
	dim fwResposta
	
	dbNomeTabela			= Request("dbNomeTabela")
	dbNomeCampo				= Request("dbNomeCampo")
	dbCampoCodigo			= Request("dbCampoCodigo")
	dbValorCampoCondicao	= Request("dbValorCampoCondicao")
	dbCampoResposta			= Request("dbCampoResposta")
	dbCampoAtualizacaoTipo	= Request("dbCampoAtualizacaoTipo")
	novoValor				= Request("novoValor")
	doWrite					= Request("doWrite")
	didAction				= false
	fwResposta				= ""
	
	if isNullOrEmpty(dbCampoResposta) then
		dbCampoResposta = dbNomeCampo
	end if
	
	if novoValor <> "" then
		valorLimpo = limpa(novoValor)
		
		if not (lCase(dbCampoAtualizacaoTipo) = "numerico") then
			valorLimpo = "'" & valorLimpo & "'"
		end if
		
		sql = "UPDATE " & dbNomeTabela & " SET " & dbNomeCampo & " = " & valorLimpo & " WHERE " & dbCampoCodigo & " = " & dbValorCampoCondicao
		execSQL(sql)
		'Response.Write(sql)
		didAction = true
	end if
	
	Response.AddHeader "didAction", didAction
	Response.AddHeader "dbNomeTabela", dbNomeTabela
	Response.AddHeader "dbNomeCampo", dbNomeCampo
	Response.AddHeader "dbCampoCodigo", dbCampoCodigo
	Response.AddHeader "dbValorCampoCondicao", dbValorCampoCondicao
	Response.AddHeader "dbCampoResposta", dbCampoResposta
	Response.AddHeader "dbCampoAtualizacaoTipo", dbCampoAtualizacaoTipo
	Response.AddHeader "novoValor", novoValor
	
	Response.Charset = "ISO-8859-1"
	if cStr(doWrite) = "" then
		sql = "SELECT " & dbCampoResposta & " FROM " & dbNomeTabela & " WHERE " & dbCampoCodigo & " = " & dbValorCampoCondicao
		fwResposta = consultaCampo(sql)
		Response.Write(fwResposta)
	end if
%>